package net.cl.support.ui;

import java.awt.Font;
import java.util.Enumeration;

import javax.swing.ImageIcon;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;

import net.cl.utils.PathUtil;

public class DefaultUIStyle {

	public static final String FONT_FAMILY = "宋体";
	public static final int FONT_STYLE = Font.PLAIN;
	public static final int FONT_SIZE = 12;
	public static final String TREE_COLLAPSED_ICON = "resources/images/16/treeCollapsedIcon.png";
	public static final String TREE_EXPANDED_ICON = "resources/images/16/treeExpandedIcon.png";

	public DefaultUIStyle() {
		try {
			FontUIResource FONT = new FontUIResource(FONT_FAMILY, FONT_STYLE, FONT_SIZE);
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			Enumeration<Object> keys = UIManager.getDefaults().keys();
			while (keys.hasMoreElements()) {
				Object key = keys.nextElement();
				Object value = UIManager.get(key);
				if (value instanceof FontUIResource)
					UIManager.put(key, FONT);
			}
			ImageIcon treeCollapsed = new ImageIcon(PathUtil.getResourceFromRoot(TREE_COLLAPSED_ICON));
			ImageIcon treeExpanded = new ImageIcon(PathUtil.getResourceFromRoot(TREE_EXPANDED_ICON));
			UIManager.put("Tree.collapsedIcon", treeCollapsed);
			UIManager.put("Tree.expandedIcon", treeExpanded);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
